<?php

namespace console\models\app_tables;

use Yii;

/**
 * This is the model class for table "{{%order_cert}}".
 *
 * @property Order $order
 */
class OrderCert extends \common\models\credit_app\OrderCert
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return '{{%order_cert}}';
    }

    /**
     * @return \yii\db\Connection the database connection used by this AR class.
     */
    public static function getDb()
    {
        return Yii::$app->db_app;
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['ct_oid', 'ct_attach', 'ct_name', 'ct_code', 'ct_sex', 'ct_birth', 'ct_affiliation', 'ct_idaddress', 'ct_validity_start', 'ct_validity_end', 'ct_remark', 'ct_detail', 'ct_dateline'], 'required'],
            [['ct_oid', 'ct_dateline', 'ct_skip'], 'integer'],
            [['ct_key', 'ct_attach', 'ct_sex', 'ct_remark', 'ct_detail', 'ct_results', 'ct_status'], 'string'],
            [['ct_birth', 'ct_validity_start', 'ct_validity_end'], 'safe'],
            [['ct_name', 'ct_code'], 'string', 'max' => 30],
            [['ct_affiliation', 'ct_idaddress'], 'string', 'max' => 50],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'ct_id' => 'Ct ID',
            'ct_oid' => 'Ct Oid',
            'ct_key' => 'Ct Key',
            'ct_attach' => 'Ct Attach',
            'ct_name' => 'Ct Name',
            'ct_code' => 'Ct Code',
            'ct_sex' => 'Ct Sex',
            'ct_birth' => 'Ct Birth',
            'ct_affiliation' => 'Ct Affiliation',
            'ct_idaddress' => 'Ct Idaddress',
            'ct_validity_start' => 'Ct Validity Start',
            'ct_validity_end' => 'Ct Validity End',
            'ct_remark' => 'Ct Remark',
            'ct_detail' => 'Ct Detail',
            'ct_dateline' => 'Ct Dateline',
            'ct_results' => 'Ct Results',
            'ct_skip' => 'Ct Skip',
            'ct_status' => 'Ct Status',
        ];
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getOrder()
    {
        return $this->hasOne(Order::className(), ['o_id' => 'ct_oid']);
    }
}